import request from "../../services/index"
import { IResponse, LoginResult, RegisterResult } from "../../types/common"
import { LoginParams, RegisterParams, SendEmailCodeParams } from "../../types/user"
// 用户基本api

export async function loginApi(params: LoginParams) {
    return request.post<IResponse<LoginResult>>('/api/auth/login', params);
}

export async function registerApi(params: RegisterParams) {
    return request.post<IResponse<RegisterResult>>('/api/auth/register', params);
}
// 获取用户权限
export async function getUserPermissions() {
    return request.get<IResponse<string[]>>('/api/auth/permiss');
}

// 获取角色列表
export async function getRoles() {
    return request.get<IResponse<string[]>>('/api/auth/role');
}
// 发送邮箱验证码
export async function sendEmailCode(params: SendEmailCodeParams) {
    return request.post<IResponse<string>>('/api/auth/send_email_code', params);
}
// 发送手机验证码s
export async function sendPhoneCode(cellphone: string) {
    return request.post<IResponse<string>>('/api/auth/code', { cellphone });
}